//
//  BaseButton.m
//  EggSteward
//
//  Created by 王道林 on 16/8/27.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "BaseButton.h"

@implementation BaseButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"day" object:nil];
    
}


- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUp];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUp];
    }
    return self;
}

- (void)setUp
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(night:) name:@"night" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dayTime:) name:@"day" object:nil];
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    BOOL is = [userDefault boolForKey:@"night"];
    if (is) {
        [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil userInfo:nil];
    } else
    {
//        [[NSNotificationCenter defaultCenter] postNotificationName:@"day" object:nil userInfo:nil];
    }
    
}
- (void)night:(NSNotification *)sender
{
//    self.backgroundColor = [UIColor grayColor];
}
- (void)dayTime:(NSNotification *)sender
{
//    self.backgroundColor = [UIColor whiteColor];
}


@end
